#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include<QPainter>
#include<QKeyEvent>
#include<QTimer>
#include"snake.h"
#include"food.h"
#include<QMessageBox>
#include<QLabel>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void paintEvent(QPaintEvent*);//重写绘图事件
    void gameover();
    bool isgameover();

private:
    Ui::MainWindow *ui;

    int core=0;
    snake snake;
    char key='d';
    food food;
    QTimer *timer=new QTimer(this);
    int timerspeed=200;
    bool bugflag=false;
    void keyPressEvent(QKeyEvent*ev);
};
#endif // MAINWINDOW_H
